Bee.grid.PageGrid = Ext.extend(Bee.grid.ListGrid, {
    pageSize: 20,
    // private
    initBbar: function(){
        if (this.bbar !== false) {
            this.bbar = new Ext.PagingToolbar({
                store: this.ds,
                pageSize: this.pageSize,
                displayInfo: true
            });
        }
    },
    // private
    initDs: function(){
        if (!this.ds && this.recordHeaders) {
            this.ds = new Ext.data.Store({
                proxy: new Bee.data.DWRPageProxy(this.dwr.call, this.dwr.config, this),
                reader: new Bee.data.DWRPageReader(this.pagemeta, this.recordHeaders),
                remoteSort: true
            });
            delete this.recordHeaders;
        }
    },
    // overwrite
    onRender: function(ct, position){
        this.filter = this.filter ? this.filter : {};
        this.like = this.like ? this.like : {};
        this.sort = this.sort ? this.sort : {};
        Bee.grid.PageGrid.superclass.onRender.call(this, ct, position);
        var bbar = this.getBottomToolbar();
        bbar.pageSizeSel = new Ext.form.ComboBox({
            editable: false,
            width: 45,
            typeAhead: false,
            triggerAction: 'all',
            mode: 'local',
            store: new Ext.data.ArrayStore({
                fields: ['value', 'text'],
                data: [[1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [10, '10'], [20, '20'], [50, '50'], [100, '100']]
            }),
            valueField: 'value',
            displayField: 'text',
            value: this.pageSize,
            listeners: {
                'select': function(o, r){
                    this.pageSize = r.get('value');
                    this.ownerCt.pageSize = r.get('value');
                    this.doLoad(this.cursor);
                },
                scope: bbar
            }
        });
        //pageSizeSel错误:
        //假设总共有40条记录,设置每页显示20条,点击最后一页后,再选择每页显示100条数据时当前页码出错。
        //bbar.insert(11, bbar.pageSizeSel);
    }
});

Ext.reg('pgrid', Bee.grid.PageGrid);
